/*
 * SpaceSearch.h
 *
 *  Created on: Dec 9, 2009
 *      Author: svilen
 */

#ifndef SPACESEARCH_H_
#define SPACESEARCH_H_
#include "vision_client.h"

#define BALL_DIAMETER 50.8
#define MAX_DISTANCE 1000

//Equal to 0.5 degrees
#define ANGLE_RESOLUTION 0.00872664626
#define DISTANCE_RESOLUTION 1

struct State {
	double alpha;
	double beta;
	double dist;
	double diam;
};


class SpaceSearch {
private:
	vision_client* client;
	virtual void Init() = 0;
protected:
	long iteration;
	double Fitness(State* state);

public:
	SpaceSearch(vision_client* _client);
	virtual ~SpaceSearch();

	virtual void DoSearch(float &alpha, float &beta, float &dist, float &diam) = 0;

	double RandomDouble(double min, double max);
};

class GradientSearch : SpaceSearch {
private:
	State curr_state;
	State* neighbour_states;
	vector<struct State*> neighbours;


	static const double good_threshold = 0.8;

	void GenerateSuccessors();
	void Init();
public:
	GradientSearch(vision_client* _client);
	~GradientSearch();
	void DoSearch(float &alpha, float &beta, float &dist, float &diam);

};

#endif /* SPACESEARCH_H_ */
